/***************************************************************************
 *   Copyright (C) 2007 by Phillip Aldridge   *
 *   phillip@imi21.com    *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef GRAPHVIEW_H
#define GRAPHVIEW_H
#include <qwidget.h>
#include <qpen.h>
#include <qpainter.h>
#include <qpixmap.h>
#include <qlist.h>
#include <qvaluelist.h>
#include <qstringlist.h>

#include <qframe.h>
#include <qdatetime.h>
#include <qwidget.h>
/**
	@author Phillip Aldridge <phillip@imi21.com>
*/

class GraphView : public QWidget
{
Q_OBJECT

public:
    GraphView(QWidget *parent = 0, const char *name = 0);

    ~GraphView();
   void setWindValues( QValueList<float> v );
   void setTempNowValues( QValueList<float> v );
   void setTempMaxValues( QValueList<float> v );
   void setTempMinValues( QValueList<float> v );
   void setRelPressureValues( QValueList<float> v );
   void setDewpointValues( QValueList<float> v );
   void setHumidityValues( QValueList<float> v );
   void setRainValues( QValueList<float> v );

void print( QPainter *p );

private:
   void setVScalling(int pMax, int pMin, int s, int z );
   int vPosMax, vPosMin, vRange, vStep, vZero;
   float vScale;

   int vPos( float p);
   int width,height;

   int gx1,gx2, gy1, gy2, graphW , graphH, yAxis;

    QSizePolicy sizePolicy() const;
    QSize sizeHint() const;
   void resizeEvent( QResizeEvent * );

protected:
   void drawLabel( QPainter*,int originX, int originY, QString s );
   void plotData( QPainter* );
   void drawBarChart( QPainter*, QValueList<float>, int originX, int originY );
   void drawLineChart( QPainter*, QValueList<float>, int originX, int originY );
   void drawBoxes( QPainter* p );
   void drawGridH(QPainter* p, int originX, int originY, int count);
   void drawGrid(QPainter* p, int originX, int originY);
   void drawGridRight(QPainter* p, int originX, int originY);
   void paintEvent( QPaintEvent * );


   QString xTitle,yTitle;
   QValueList<float> yValues;
   QValueList<float> valuesWind;
   QValueList<float> valuesTempNow; //used for average
   QValueList<float> valuesTempMax;
   QValueList<float> valuesTempMin;
   QValueList<float> valuesRelPressure;
   QValueList<float> valuesDewpoint;
   QValueList<float> valuesHumidity;
   QValueList<float> valuesRain;

  signals:
        void message( QString );
};

#endif
